package com.zhou.JavaAndroidFirm.widget.imgsel;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Administrator
 * @date 2018/8/13 0013
 * @des
 */
public class ImagePagerFragment extends Fragment {

    public final static String ARG_PATH = "PATHS";
    public final static String ARG_CURRENT_ITEM = "ARG_CURRENT_ITEM";

    private ArrayList<String> paths;
    private ViewPager mViewPager;

    private int currentItem = 0;

    public static ImagePagerFragment newInstance(List<String> paths, int currentItem) {

        ImagePagerFragment f = new ImagePagerFragment();

        Bundle args = new Bundle();
        args.putStringArray(ARG_PATH, paths.toArray(new String[paths.size()]));
        args.putInt(ARG_CURRENT_ITEM, currentItem);

        f.setArguments(args);

        return f;
    }

    public ArrayList<String> getCurrentPath() {
        ArrayList<String> list = new ArrayList<>();
        int position = mViewPager.getCurrentItem();
        if (paths != null && paths.size() > position) {
            list.add(paths.get(position));
        }
        return list;
    }

}
